package com.oschina.wed.dal.dao;

import com.oschina.wed.dal.BaseTransactionService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.support.TransactionTemplate;

import javax.annotation.Resource;

/**
 * @author lujiang
 */
@Component("baseTransactionService")
public class BaseTransactionServiceImpl implements BaseTransactionService {
	@Resource(name = "txManager")
	private PlatformTransactionManager txManager;

	@Override
	public TransactionTemplate getTransactionManager() {
		TransactionTemplate template = new TransactionTemplate(txManager);
		template.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
		return template;
	}

	public PlatformTransactionManager getTxManager() {
		return txManager;
	}

	public void setTxManager(PlatformTransactionManager txManager) {
		this.txManager = txManager;
	}
}
